{extend name="public/base"/}
{block name="body"}
<link rel="stylesheet" type="text/css" href="/static/css/boxImg.css">
<style type="text/css">
	.attrs{margin-top:5px;}
	.attrname{width:100px;border:solid 1px #ddd;height:31px;font-size:14px;padding-left:4px;}
	.attrval{width:40%;border:solid 1px #ddd;height:31px;font-size:14px;padding-left:4px;}
	.status{width:60px;height:60px;background-color:#dddddd;border-radius:30px;float:left;text-align: center;margin-right:10px;}
	.status p{font-size:10px;color:#ffffff;margin-bottom:0;}
	.status p:first-child{margin-top:10px;}
	.active{background-color:#2eb51c !important;}
</style>
<title>详情</title>
</head>
<body>
<article class="page-container">
	<form class="form form-horizontal" id="form-admin-add">
		<input type="hidden" class="input-text" value="{$data.id}" id="id" name="id">
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">订单号：</label>
			<div class="formControls col-xs-8 col-sm-9">

				{foreach $datas as $k=>$v}
					【{$v.ordernosub}】
				{/foreach}
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">标题：</label>
			<div class="formControls col-xs-8 col-sm-9">
				{foreach $datas as $k=>$v}
					【{$v.title}】
				{/foreach}
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">图片：</label>
			<div class="formControls col-xs-8 col-sm-9">
				{foreach $datas as $k=>$v}
					<img modal="zoomImg" style="width:25%" src="{$v.img}">
				{/foreach}
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">规格参数：</label>
			<div class="formControls col-xs-8 col-sm-9">
				{foreach $datas as $k=>$v}
					【{$v.combination}】
				{/foreach}
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">单价：</label>
			<div class="formControls col-xs-8 col-sm-9">
				{foreach $datas as $k=>$v}
					【{$v.price}】
				{/foreach}
			</div>
			
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">购买量：</label>
			<div class="formControls col-xs-8 col-sm-9">
				
				{foreach $datas as $k=>$v}
					【{$v.buy_num}】
				{/foreach}
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">支付费用：</label>
			<div class="formControls col-xs-8 col-sm-9">
				{$data.pay_fee}
				{if $data.state==1}
					<a title="打折" href="javascript:;" onclick="price_edits('打折','{:url('price_edits')}?id={$data.id}',{$data.id},'300','200')" class="ml-5 btn-primary radius" style="text-decoration:none">打折</a>
				{/if}
				{if $data.discount}
					原:{$data.f_pay_fee};&nbsp;&nbsp;折扣:{$data.discount};&nbsp;&nbsp;备注:{$data.remarks}
				{/if}
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">姓名：</label>
			<div class="formControls col-xs-8 col-sm-9">
				{$data.name}
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">电话：</label>
			<div class="formControls col-xs-8 col-sm-9">
				{$data.phone}
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">地址：</label>
			<div class="formControls col-xs-8 col-sm-9">
				{$data.address}
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">发票：</label>
			<div class="formControls col-xs-8 col-sm-9">
				{if $data.is_invoice==1}
				否
				{elseif $data.is_invoice==2}
					{if $data.company_name||$data.invoice_no}
						单位:{$data.company_name}/{$data.invoice_no}/{$data.invoice_address}/{$data.invoice_phone}/{$data.invoice_bank}/{$data.invoice_bank_no}
					{else}
						个人
					{/if}
					{if $data.is_invoiced==1}
					<input  onClick="invoicing({$data.id});" class="btn-primary radius" type="button" value="&nbsp;&nbsp;待开&nbsp;&nbsp;">
					{elseif $data.is_invoiced==2}
					<input class="btn-default radius" type="button" value="&nbsp;&nbsp;已开&nbsp;&nbsp;">
					{/if}
				{/if}
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">状态：</label>
			<div class="formControls col-xs-8 col-sm-9">
				{if $data.state==1}
				待付款 <input  onClick="pay_edits({$data.id});" class="btn-primary radius" type="button" value="&nbsp;&nbsp;改为已付款&nbsp;&nbsp;">
				{elseif $data.state==2}
				待发货
				{elseif $data.state=3}
				待收货
				{elseif $data.state==4}
				已完成
				{elseif $data.state==5}
				售后
				{elseif $data.state==6}
				已取消
				{/if}
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">快递方式：</label>
			<div class="formControls col-xs-8 col-sm-9">
				{if $data.express_style==1}
				普通快递
				{elseif $data.express_style==2}
				自提
				{elseif $data.express_style=3}
				货到付款
				{/if}
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">下单时间：</label>
			<div class="formControls col-xs-8 col-sm-9">
				{:date('Y-m-d H:i:s',$data.time)}
			</div>
		</div>

		{if $data.fktime}
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">付款时间：</label>
			<div class="formControls col-xs-8 col-sm-9">
				{:date('Y-m-d H:i:s',$data.fktime)}
			</div>
		</div>
		{/if}

		{if $data.fhtime}
		<div class="row cl">
			<label class="form-label col-xs-3 col-sm-2">发货时间：</label>
			<div class="formControls col-xs-8 col-sm-9">
				{:date('Y-m-d H:i:s',$data.fhtime)}
			</div>
		</div>
		{/if}

		{if $data.state==2}
			{if $data.express_style==1}
				<div class="row cl">
					<label class="form-label col-xs-3 col-sm-2">快递公司：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" value="{$data.express_company}" placeholder="快递公司" id="express_company" name="express_company">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-3 col-sm-2">快递单号：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" value="{$data.express_no}" placeholder="快递单号" id="express_no" name="express_no">
					</div>
				</div>
				<div class="row cl">
					<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
						<input id="submit" class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;发货&nbsp;&nbsp;">
					</div>
				</div>
			{else if $data.express_style==2}
				<div class="row cl">
					<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
						<input  onClick="confirm_order({$data.id});" class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;自提&nbsp;&nbsp;">
					</div>
				</div>
			{/if}
		{else}
			{if $data.state==1&&$data.express_style==3}
				<div class="row cl">
					<label class="form-label col-xs-3 col-sm-2">快递公司：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" value="{$data.express_company}" placeholder="快递公司" id="express_company" name="express_company">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-3 col-sm-2">快递单号：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" value="{$data.express_no}" placeholder="快递单号" id="express_no" name="express_no">
					</div>
				</div>
				<div class="row cl">
					<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
						<input id="submit" class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;发货&nbsp;&nbsp;">
					</div>
				</div>
				{else}
				<div class="row cl">
					<label class="form-label col-xs-3 col-sm-2">快递公司：</label>
					<div class="formControls col-xs-8 col-sm-9">
						{$data.express_company}
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-3 col-sm-2">快递单号：</label>
					<div class="formControls col-xs-8 col-sm-9">
						{$data.express_no}
					</div>
				</div>
			{/if}
			
		{/if}
		{if $back}
			<div style="border-top:1px dashed #999999;margin:10px auto;"></div>
			<div class="row cl">
				<label class="form-label col-xs-3 col-sm-2">退货退款</label>
				<div class="formControls col-xs-8 col-sm-9">
				</div>
			</div>
			
			<div class="row cl">
				<label class="form-label col-xs-3 col-sm-2">原因：</label>
				<div class="formControls col-xs-8 col-sm-9">
					{$back.reason}
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-3 col-sm-2">留言说明：</label>
				<div class="formControls col-xs-8 col-sm-9">
					{$back.message}
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-3 col-sm-2">申请时间：</label>
				<div class="formControls col-xs-8 col-sm-9">
					{:date('Y-m-d H:i:s',$back.time)}
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-3 col-sm-2">状态：</label>
				<div class="formControls col-xs-8 col-sm-9">
					{if $back.state==1}
						{if $data.state==5}
							<!-- <span class="label label-success radius" style="cursor:pointer;" onClick="agree_on({$back.id});">同意</span> -->同意
						{else}
							申请中
						{/if}
					{elseif $back.state==2}
					已同意
					{elseif $back.state==3}
						{if $data.state==5}
							<!-- <span class="label label-danger radius" style="cursor:pointer;" onClick="money_on({$back.id});">退款</span> -->退款
						{else}
							退款
						{/if}
					
					{elseif $back.state==4}
					已撤销
					{elseif $back.state==5}
					退款成功
					{/if}
					<i style="font-size:10px;">(1:申请中“同意”;2:已同意;3退款;4已撤销;5退款成功)</i>
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-3 col-sm-2">快递公司：</label>
				<div class="formControls col-xs-8 col-sm-9">
					{$back.express_company}
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-3 col-sm-2">快递单号：</label>
				<div class="formControls col-xs-8 col-sm-9">
					{$back.express_no}
				</div>
			</div>
		{/if}

	</form>
</article>


<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/static/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="/static/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="/static/lib/jquery.validation/1.14.0/messages_zh.js"></script> 
<script type="text/javascript" src="/static/js/boxImg.js"></script>
<script type="text/javascript">
$("#submit").click(function() {
	layer.load(1, {
	  shade: [0.1,'#fff'] //0.1透明度的白色背景
	});
	var id=$("input[name=id]").val();
	var express_company=$("input[name=express_company]").val();
	var express_no=$("input[name=express_no]").val();
    $.ajax({
	    type: 'POST',
	    url: "{:url('order_details')}",
	    data: {id:id,express_company:express_company,express_no:express_no},
	    success: function(resdata){
	        if(resdata.code==200){
				layer.msg(resdata.msg,{icon:1,time:1000});
				setTimeout("parent.location.reload()",1000);
	        }else{
				layer.msg(resdata.msg,{icon:2,time:3000});
	        }
	    },
	    error: function(){
			layer.msg('数据保存失败',{icon:2,time:3000});
	    }
	})
})
// function agree_on(id){
// 	layer.confirm('确定吗？',function(index){
// 		$.ajax({
// 			type: 'POST',
// 			url: 'agree_on',
// 			data:{id:id},
// 			success: function(data){
// 				if(data.code==200){
// 		            location.reload()
// 		        }else{
// 					layer.msg(data.msg,{icon:2,time:3000});
// 		        }
// 			},
// 			error:function(data) {
// 				console.log(data.msg);
// 			},
// 		});		
// 	});
// }
// function money_on(id){
// 	layer.confirm('确认要放款？',function(index){
// 		$.ajax({
// 			type: 'POST',
// 			url: 'money_on',
// 			data:{id:id},
// 			success: function(data){
// 				if(data.code==200){
// 		            location.reload()
// 		        }else{
// 					layer.msg(data.msg,{icon:2,time:3000});
// 		        }
// 			},
// 			error:function(data) {
// 				console.log(data.msg);
// 			},
// 		});		
// 	});
// }
function confirm_order(id){
	layer.confirm('确认自提？',function(index){
		$.ajax({
			type: 'POST',
			url: 'confirm_orders',
			data:{id:id},
			success: function(data){
				if(data.code==200){
		            location.reload()
		        }else{
					layer.msg(data.msg,{icon:2,time:3000});
		        }
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}
function pay_edits(id){
	layer.confirm('确认改为已付款？',function(index){
		$.ajax({
			type: 'POST',
			url: 'pay_edits',
			data:{id:id},
			success: function(data){
				if(data.code==200){
		            location.reload()
		        }else{
					layer.msg(data.msg,{icon:2,time:3000});
		        }
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}
function invoicing(id){
	layer.confirm('确认已开发票？',function(index){
		$.ajax({
			type: 'POST',
			url: 'invoicings',
			data:{id:id},
			success: function(data){
				if(data.code==200){
		            location.reload()
		        }else{
					layer.msg(data.msg,{icon:2,time:3000});
		        }
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}
function price_edits(title,url,id,w,h){
	layer_show(title,url,w,h);
}
</script> 
{/block}